<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>

      // function  Student(name){
      //   this.name = name;
      // }
      // //给student新增一个方法
      // Student.prototype.hello = function (){
      //   alert("Hello")
      // }

      //ES6 之后
      class Student{
        constructor(name) {
          this.name= name;
        }
        hello(){
          alert('hello')
        }
      }

      class XiaoStudent extends Student{
        constructor(name,grade) {
          super(name);
          this.grade = grade;
        }
        myGrade(){
          alert('i am student')
        }

      }
      var xiaoming = new Student("xiaoming");
      var xiaohong = new XiaoStudent("xiaoming",1)
      xiaoming.hello();
      console.log(xiaohong)
      xiaohong.myGrade();
    </script>
</body>
</html>